const int led1 = 9;
const int led2 = 10;
const int door = 11;
boolean  doorstate;

void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(door, INPUT);

Serial.begin(9600);

}

void loop() {
        if(digitalRead(door) == HIGH) {
          digitalWrite(led2) = doorstate;
          
        }
  
        if (Serial.available() > 0) { // when you receive data:  
          char input = char(Serial.read());
          switch (input) {
            case 117:                            //  case " u " door unlocked
              if(digitalRead(door) == HIGH) {        //  only if door is locked
                digitalWrite(led1, HIGH);
                delay(1000);
                digitalWrite(led1, LOW);
                delay(1000);
                digitalWrite(led1, HIGH);
                delay(1000);
                digitalWrite(led1, LOW);
                digitalWrite(led2, LOW);
              }
              break;
              
            case 108:                  //  case " l " door locked
              if(door == LOW) {       //  only if door is open
                digitalWrite(led1, HIGH);
                delay(1000);
                digitalWrite(led1, LOW);
                digitalWrite(led2, HIGH);
              }
              break;
          }
        }
  
}
